how to read particular line of file in c#

61

how to read particular line of file in c# -

string GetLine(string fileName, int line)
{
   using (var sr = new StreamReader(fileName)) {
       for (int i = 1; i < line; i++)
          sr.ReadLine();
       return sr.ReadLine();
   }
}

Comments

Submit
0 Comments